import Vue from 'vue'
import Loading from './loading.vue'

const LoadingConstructor = Vue.extend(Loading)

LoadingConstructor.prototype.show = (title) => {
  instance.title = title || '请稍等...'
  document.body.appendChild(instance.$el)
}

LoadingConstructor.prototype.close = function () {
  const el = instance.$el
  el.parentNode && el.parentNode.removeChild(el)
}

const instance = new LoadingConstructor({
  el: document.createElement('div')
})

export default {
  show: instance.show,
  close: instance.close
}

